package com.example.a20112.ui_demo;

import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a20112.ui_demo.adapter.FoodListAdapter;
import com.example.a20112.ui_demo.beans.FoodListBean;
import com.example.a20112.ui_demo.listener.RetrofitListener;
import com.example.a20112.ui_demo.model.Constants;
import com.example.a20112.ui_demo.model.UserModel;

import java.util.List;

public class FoodListActivity extends BaseActivity implements RetrofitListener {

    private RecyclerView recyclerView;
    private List<FoodListBean> beans;
    private TextView name,price,phonenum;
    private  Boolean flagcollect = false;
    private FoodListAdapter adapter;
    private ImageView image;
    private int shop_id;
    private String user_id,shop_food_id,flag;


   void initViews() {
       setLayout(R.layout.item_foodlist);
       name = (TextView) findViewById(R.id.fo_name);
       image=(ImageView)findViewById(R.id.fo_image);
       price=(TextView) findViewById(R.id.fo_price);
       phonenum=(TextView) findViewById(R.id.phonenum);


//        adapter = new FoodListAdapter();
//        recyclerView = findViewById(R.id.rv_foodlist);
//        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
//        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.setLayoutManager(layoutManager);
//        recyclerView.setAdapter(adapter);
//        recyclerView.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
    }


     void initEvents() {

    }


     void initData() {

    }
private void getFoodList(){
    UserModel userModel = new UserModel();
    userModel.getFoodByShop(shop_id,this);

}
  private void iscollected(){
      UserModel userModel = new UserModel();

  }
private void collect(){

}

    @Override
    public void onSuccess(Object o,int flag) {
switch (flag)
{
    case Constants.GETFOODBYSHOP:
     adapter=new FoodListAdapter(FoodListActivity.this,(List<FoodListBean>)o,R.layout.item_foodlist,phonenum);
     recyclerView.setAdapter(adapter);

        break;
//    case Constants.ISCOLLECTED:
//        break;
//    case Constants.USERCOLLECTFOOD:
//        break;

}
    }

    @Override
    public void onFail() {
showToast("网络连接错误");
    }
}


